package com.cxl.price.bean;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.summer.core.common.BeanName;
import com.summer.core.entity.BaseBean;
/**
 * jpa多对多双向关联映射
 * @author Administrator
 *
 */
@Entity
@Table(name="good")
@BeanName("商城商品")
public class Good extends BaseBean{

	private static final long serialVersionUID = -5839437593679260468L;
	
	//名称
	private String title;
	
	//商品url地址
	private String url;
	
	//历史高价
	private double high_price;
	
	//历史低价
	private double low_price;
	
	//产品描述
	private String content;
	
	//商城
	private Shop shop;
	
	//当前售价
	private double price;
	
	//主图片地址
	private String pic_url;
	
	
	private boolean is_master;
	
	
	private String sku;//商家 商品编码 
	
	private Goods  goods;
	

	
	
//	@ManyToMany
//	@JoinTable(
//			name="good_goods",
//			joinColumns={@JoinColumn(name="good_id")},
//			inverseJoinColumns={@JoinColumn(name="goods_id")}//对面的字段
//			)
    @ManyToOne(
            cascade ={CascadeType.REFRESH},
            fetch=FetchType.LAZY
    )
//	@JoinTable(
//			name="good_goods",
//			joinColumns={@JoinColumn(name="good_id")},
//			inverseJoinColumns={@JoinColumn(name="goods_id")}//对面的字段
//			)
//	public Set<Goods> getGoods() {
//		return goods;
//	}
//
//	public void setGoods(Set<Goods> goods) {
//		this.goods = goods;
//	}
    public Goods getGoods() {
		return goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}
    

	public String getTitle() {
		return title;
	}

	

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(length=10000)
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public double getHigh_price() {
		return high_price;
	}

	public void setHigh_price(double highPrice) {
		high_price = highPrice;
	}

	public double getLow_price() {
		return low_price;
	}

	public void setLow_price(double lowPrice) {
		low_price = lowPrice;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	/**
	//产品
	private Product product;
	
	@ManyToOne(cascade=CascadeType.REFRESH,fetch = FetchType.LAZY)
	@JoinColumn(name = "product_id")
	public Product getProduct() {
		return product;
	}

	
	public void setProduct(Product product) {
		this.product = product;
	}**/
	

	@ManyToOne(cascade=CascadeType.REFRESH,fetch = FetchType.EAGER)
	@JoinColumn(name = "shop_id")
	public Shop getShop() {
		return shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
	}

	
	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}
	
	

	@Column(length=3000)
	public String getPic_url() {
		return pic_url;
	}

	public void setPic_url(String picUrl) {
		pic_url = picUrl;
	}

	public boolean isIs_master() {
		return is_master;
	}

	public void setIs_master(boolean isMaster) {
		is_master = isMaster;
	}

	public String getSku() {
		return sku;
	}

	public void setSku(String sku) {
		this.sku = sku;
	}
    
	
	
    
	
}